<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title> <?php echo ($action); ?> | <?php echo get_opinion('title');?></title>

    <meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'>

<meta name="renderer" content="webkit|ie-comp|ie-stand">

<meta name="description" content="DJCMS"/>
<meta name="keywords" content="DJCMS"/>
<!-- bootstrap 3.0.2 -->
<link href="/php_now/djcms/Public/AdminLTE/css/bootstrap.min.css" rel="stylesheet" type="text/css"/>
<!-- font Awesome -->
<link href="/php_now/djcms/Public/AdminLTE/css/font-awesome.css" rel="stylesheet" type="text/css"/>
<!-- Ionicons -->
<link href="/php_now/djcms/Public/AdminLTE/css/ionicons.min.css" rel="stylesheet" type="text/css"/>
<!-- Theme style -->
<link href="/php_now/djcms/Public/AdminLTE/css/AdminLTE.css" rel="stylesheet" type="text/css"/>

<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script type="text/javascript" src="/php_now/djcms/Public/share/js/html5.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
<![endif]-->

<!-- jQuery 2.0.2 -->
<!--<script type="text/javascript" src="/php_now/djcms/Public/share/js/jquery-2.0.2.min.js"></script>-->
<script type="text/javascript" src="/php_now/djcms/Public/share/js/jquery-1.9.0.min.js"></script>


<style>

    .form-group .control-label {

        float: left;
        width: 150px;
        padding-top: 5px;
        text-align: right;
        line-height: 24px;
    }

    .form-group .controls {

        margin-left: 170px;
    }

    .form-group .controls .radio {
        display: inline;
        padding-left: 0px;
        padding-right: 20px;
        vertical-align: baseline;
        line-height: 30px;
    }

    .form-group .controls .large {

        width: 60%;
    }

    .form-group .controls select {

        width: 60%;
    }

    .form-group .controls .form-control {

        display: inline;
    }

    .form-group .controls .help-inline {
        padding-left: 10px;
        color: #595959;
    }

    .form-actions {

        margin-left: 170px;
    }

    .dropdown-checkboxes div {
        padding: 1px;
        padding-left: 10px;
    }

    .btn {
        margin: 2px;

    }

    .pagination {
        margin: 0px 0;
    }

</style>

</head>
<body class="skin-blue">

<?php echo W('Common/header');?>

<div class="wrapper row-offcanvas row-offcanvas-left">
    <?php echo W('Common/sideMenu');?>


    <!-- Right side column. Contains the navbar and content of the page -->
    <aside class="right-side">
        <!-- Content Header (Page header) -->


        <section class="content-header">
            <h1>
                <?php echo ($action); ?>
                <small><?php echo get_opinion('title');?></small>
            </h1>
            <ol class="breadcrumb">
                <li><a href="<?php echo ($module_url); ?>"><i class="fa fa-dashboard"></i> <?php echo ($module); ?></a></li>
                <li class="active"><?php echo ($action); ?></li>
            </ol>
        </section>

        <!-- Main content -->
        <section class="content">

            <div class="row">
                <div class="col-md-12">

                    <!-- /.box-header -->
                    <div class="box-body">


                        <form method="POST" action="<?php echo U('Admin/Posts/indexHandle');?>" id="posts">
                            <div class="portlet-body">
                                <div class="row" style="padding-bottom: 10px;">

                                    <div class="col-md-4">
                                        <div class="btn-group">
                                            <a href="<?php echo U('Admin/Posts/add');?>">
                                                <button type="submit" class="btn btn-success" name="postAdd"
                                                        value='1'>
                                                    <i class="icon-plus"></i> 发布文章
                                                </button>
                                            </a>

                                        </div>

                                        <div class="btn-group">
                                            <button type="submit" class="btn btn-info" name="verifyAll" value='1'><i
                                                    class="icon-user icon-white"></i> 批量送审
                                            </button>
                                        </div>

                                        <div class="btn-group">
                                            <button type="submit" class="btn btn-danger" name="delAll" value='1'><i
                                                    class="icon-remove icon-white">
                                            </i> 批量删除
                                            </button>
                                        </div>


                                    </div>

                                    <div class="col-md-5">
                                        <label>分页:</label>
<select style="width:100px"
        onchange="self.location.href=options[selectedIndex].value"
        size="1"
        name="mlink2">
    <option value="/php_now/djcms/index.php?m=admin&c=posts&a=index&page=<?php echo get_opinion('PAGER');?>">选择分页</option>

    <option value="/php_now/djcms/index.php?m=admin&c=posts&a=index&page=5">5</option>
    <option value="/php_now/djcms/index.php?m=admin&c=posts&a=index&page=10">10</option>
    <option value="/php_now/djcms/index.php?m=admin&c=posts&a=index&page=20">20</option>
    <option value="/php_now/djcms/index.php?m=admin&c=posts&a=index&page=100">100</option>
</select>
&nbsp;&nbsp;

<label>分类:</label>
<select style="width:100px"
        onchange="self.location.href=options[selectedIndex].value"
        size="1"
        name="mlink2">
    <option value="/php_now/djcms/index.php?m=admin&c=posts&a=index">筛选分类</option>

    <?php if(is_array($cats)): foreach($cats as $key=>$cat): ?><option value="?m=Admin&c=Posts&a=index&cat=<?php echo ($cat["cat_id"]); ?>"> <?php echo ($cat["cat_slug"]); ?></option><?php endforeach; endif; ?>

</select>
                                    </div>

                                    <div class="col-md-3">
                                        <label>搜索:</label>
<input type="text" name="keyword" class=" large" style="padding-left: 5px"
       placeholder="输入关键字,回车搜索" value="<?php echo I('get.keyword');?>"/>
<input type="hidden" name="post_type" value="<?php echo ($post_type); ?>"/>
                                       
                                    </div>

                                </div>
                                <table class="table table-striped table-bordered table-hover"
                                       id="post_table">
                                    <thead>
                                    <tr>
                                        <th style="width: 8px;"><input type="checkbox" class="group-checkable"
                                                                       id="check-all"
                                                                       data-set="#post_table .checkboxes"/></th>
                                        <th class="col-md-3">标题</th>
                                        <th class="col-md-1" style="width: 100px">作者</th>
                                        <th >分类 与 标签 (最多显示5个)</th>
                                        <th class="col-md-1" style="width: 140px">发布日期</th>
                                        <th style="width: 230px">操作</th>

                                    </tr>
                                    </thead>
                                    <tbody id="cache_table">
                                    <?php if(is_array($posts)): foreach($posts as $key=>$v): ?><tr class="odd gradeX">
                                            <td><input type="checkbox" class="checkboxes" value="<?php echo ($v['post_id']); ?>"
                                                       name="posts[]"/>
                                            </td>
                                            <td><a href="<?php echo U('Admin/Posts/posts', array('id' => $v['post_id']));?>"
                                                   title="<?php echo ($v["post_title"]); ?>"><?php echo ($v["post_title"]); ?></a></td>
                                            <td>
                                                <a href=" /php_now/djcms/index.php?m=admin&c=posts&a=index&uid=<?php echo ($v['post_user']['user_id']); ?>"><?php echo ($v["post_user"]["user_nicename"]); ?></a>
                                            </td>
                                            <td>
                                                分类:
                                                <?php if(is_array($v['post_cat'])): $i = 0; $__LIST__ = array_slice($v['post_cat'],0,5,true);if( count($__LIST__)==0 ) : echo "无分类" ;else: foreach($__LIST__ as $key=>$v_pcs): $mod = ($i % 2 );++$i;?><a
                                                            href="<?php echo U('Admin/Posts/index', array('cat' => $v_pcs['cat_id']));?>"><?php echo ($v_pcs['cat_name']); ?></a>&nbsp;&nbsp;<?php endforeach; endif; endif; ?>
                                                标签:
                                                <?php if(is_array($v['post_tag'])): $i = 0; $__LIST__ = array_slice($v['post_tag'],0,5,true);if( count($__LIST__)==0 ) : echo "无标签" ;else: foreach($__LIST__ as $key=>$v_pts): $mod = ($i % 2 );++$i;?><a
                                                            href="<?php echo U('Admin/Posts/index', array('tag' => $v_pts['tag_id']));?>"><?php echo ($v_pts['tag_name']); ?></a>&nbsp;&nbsp;<?php endforeach; endif; endif; ?>
                                            </td>
                                            <td><?php echo getTimestamp($v['post_date'],'Y-m-d H:i') ;?></td>
                                            <td>
                                                <a class="btn btn-sm btn-primary"
                                                   href="<?php echo U('Admin/Posts/posts', array('id' => $v['post_id']));?>">编辑</a>

                                                <a class="btn btn-sm btn-info"
                                                   href="<?php echo U('Home/Post/'.$v['post_type'], array('info' => $v['post_id']));?>"
                                                   target="_blank">查看</a>

                                                <a class="btn btn-sm btn-warning"
                                                   href="<?php echo U('Admin/Posts/unverifiedHandle', array('id' => $v['post_id'],'post_status' => 'unverified'));?>">送审</a>

                                                <a class="btn btn-sm btn-danger"
                                                   onclick="javascript:return a_confirm()"
                                                   href="<?php echo U('Admin/Posts/preDel', array('id' => $v['post_id']));?>">删除</a>
                                            </td>


                                        </tr><?php endforeach; endif; ?>
                                    </tbody>
                                </table>
                                <div>
                                    <ul class="pagination"> <?php echo ($pager); ?></ul>
                                </div>
                            </div>
                        </form>


                    </div>
                </div>

            </div>


        </section>
        <!-- /.content -->
    </aside>
    <!-- /.right-side -->
</div>
<!-- ./wrapper -->

<!-- Bootstrap -->
<script src="/php_now/djcms/Public/AdminLTE/js/bootstrap.min.js" type="text/javascript"></script>
<!-- AdminLTE App -->
<script src="/php_now/djcms/Public/AdminLTE/js/AdminLTE/app.js" type="text/javascript"></script>

<!-- iCheck -->
<script src="/php_now/djcms/Public/AdminLTE/js/plugins/iCheck/icheck.min.js" type="text/javascript"></script>

<script>
    function a_confirm() {
        var msg = "您真的确定要这样做么吗？\n\n请确认！";
//        alert(msg);

        if (confirm(msg) == true) {
            return true;
        } else {
            return false;
        }
    }

</script>


<script>


    function refreshWarningNum(selector1) {
        var num = $(selector1).find("li").length;
        $("#warning_box_num").html(num);
        $("#warning_box_num2").html(num);

    }


    //require iCheck
    $(document).ready(function () {


        $("input[type='checkbox'], input[type='radio']").iCheck({
            checkboxClass: 'icheckbox_minimal',
            radioClass: 'iradio_minimal'
        });


        $('#check-all').on('ifChecked', function (event) {
            $('input').iCheck('check');
        });
        $('#check-all').on('ifUnchecked', function (event) {
            $('input').iCheck('uncheck');
        });
    });
</script>


<script>
        function fetchWarningList() {
            var url = '<?php echo U("Admin/Index/checkTodo");?>';
            $.get(url, function (data) {
                if (data != 'none') {
                    $('#warning_box').html(data);
                    refreshWarningNum('#warning_box');
                } else {
                    $('#warning_box').html("");
                    refreshWarningNum('#warning_box');
                }
            });
        }
        function clearWarningList() {
            var url = '<?php echo U("Admin/Index/checkTodoCacheClear");?>';
            $.get(url, function (data) {
            });
            fetchWarningList();
        }

        $(document).ready(function () {

            fetchWarningList();

            $('.notifications-menu').click(function () {
                clearWarningList();
            });


        });



    </script>

<script>

        $(document).ready(function () {
            try
            {
                fetchPostCount();
            }
            catch (e)
            {

            }
        });


        function fetchPostCount() {
            var url = '<?php echo U("Admin/Posts/countAll");?>';
            $.get(url, function (data) {
                if (data != 'none') {

                    /**
                     * {
                        status: 1,
                        info: {
                        publish: "4514",
                        unverified: "0",
                        reverify: "0",
                        draft: "4",
                        preDel: "1"
                        },
                        url: ""
                        }
                     */
                    var dataObj = eval("(" + data + ")");//转换为json对象
                    var obj = jQuery.parseJSON(data);


                    $('#admin-posts-index a').append('<small class="badge pull-right bg-green">' + obj.info.single.publish + '</small>');
                    $('#admin-posts-page a').append('<small class="badge pull-right bg-green">' + obj.info.page.publish + '</small>');

                    if (obj.info.unverified != 0) {
                        $('#admin-posts-unverified a').append('<small class="badge pull-right bg-yellow">' + obj.info.single.unverified + '</small>');
                    }

                    if (obj.info.reverify != 0) {
                        $('#admin-posts-reverify a').append('<small class="badge pull-right bg-red">' + obj.info.single.reverify + '</small>');
                    }

//                    $('#Admin-Posts-draft a').append('<small class="badge pull-right bg-yellow">'+obj.info.draft+'</small>');
//                    $('#Admin-Posts-recycle a').append('<small class="badge pull-right bg-yellow">'+obj.info.preDel+'</small>');

                } else {


                }
            });
        }
    </script>

<script>
    $(document).ready(function () {

        $('#check-all').on('ifChecked', function (event) {
            $('input').iCheck('check');
        });
        $('#check-all').on('ifUnchecked', function (event) {
            $('input').iCheck('uncheck');
        });
    });
</script>


</body>
</html>